#
# Licensed to Dagda under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Dagda licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#


import unittest
import base64
import os
from analysis.static.util.utils import extract_filesystem_bundle
from analysis.static.util.utils import clean_up
from analysis.static.util.utils import _get_layers_from_manifest
from driver.docker_driver import DockerDriver


# -- Test suite

class UtilsTestSuite(unittest.TestCase):

    def test_extract_filesystem_bundle_and_clean_up(self):
        temporary_dir = extract_filesystem_bundle(MockDockerDriver(), container_id='asdfi76fdgauh')
        self.assertTrue(os.path.isdir(os.path.join(temporary_dir, 'bin')))
        self.assertTrue(os.path.exists(os.path.join(temporary_dir, 'bin/bash')))
        self.assertTrue(os.path.isdir(os.path.join(temporary_dir, 'etc')))
        self.assertTrue(os.path.exists(os.path.join(temporary_dir, 'etc/daemon.conf')))
        self.assertTrue(os.path.isdir(os.path.join(temporary_dir, 'opt')))
        clean_up(temporary_dir)
        self.assertFalse(os.path.isdir(os.path.join(temporary_dir, 'bin')))
        self.assertFalse(os.path.exists(os.path.join(temporary_dir, 'bin/bash')))
        self.assertFalse(os.path.isdir(os.path.join(temporary_dir, 'etc')))
        self.assertFalse(os.path.exists(os.path.join(temporary_dir, 'etc/daemon.conf')))
        self.assertFalse(os.path.isdir(os.path.join(temporary_dir, 'opt')))

        temporary_dir = extract_filesystem_bundle(MockDockerDriver(), image_name='alpine')
        self.assertTrue(os.path.isdir(os.path.join(temporary_dir, 'bin')))
        self.assertTrue(os.path.exists(os.path.join(temporary_dir, 'bin/bash')))
        self.assertTrue(os.path.isdir(os.path.join(temporary_dir, 'etc')))
        self.assertTrue(os.path.exists(os.path.join(temporary_dir, 'etc/daemon.conf')))
        self.assertTrue(os.path.isdir(os.path.join(temporary_dir, 'opt')))
        clean_up(temporary_dir)
        self.assertFalse(os.path.isdir(os.path.join(temporary_dir, 'bin')))
        self.assertFalse(os.path.exists(os.path.join(temporary_dir, 'bin/bash')))
        self.assertFalse(os.path.isdir(os.path.join(temporary_dir, 'etc')))
        self.assertFalse(os.path.exists(os.path.join(temporary_dir, 'etc/daemon.conf')))
        self.assertFalse(os.path.isdir(os.path.join(temporary_dir, 'opt')))

    def test_get_layers_from_manifest(self):
        with open('/tmp/manifest.json', 'w') as temp_file:
            temp_file.write(manifest_json)
        layers = _get_layers_from_manifest('/tmp')
        os.remove('/tmp/manifest.json')
        self.assertEqual(layers, ['03a7cf8d4e91afbb8454bb11226daa7eb5705cb952d42e7a40dbee41ff59beac/layer.tar', '71c4cfee4e665ad522e3d1ab02b699ec2e21370c067d94fbf7e2028b4b4cd724/layer.tar', 'd55df8e0fb29678f0081a0a740e456a5325d5b29b3bcaeb66377a799c3e7245e/layer.tar', 'b85bca58d753ad29fe017a57c87dbc3dfae4317a230e2dbe785c07f46c72086e/layer.tar'])


# -- Mock classes

class MockDockerDriver(DockerDriver):
    def __init__(self):
        self.cli = None

    def get_docker_client(self):
        return self

    def get_image(self, image):
        return [base64.b64decode(mock_image_filesystem_bundle_base64)]

    def export(self, container):
        return [base64.b64decode(mock_container_filesystem_bundle_base64)]


# -- Mock Constants

mock_container_filesystem_bundle_base64 = b'b3B0LwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAwMDc3NSAAMDAxNzUw\nIAAwMDE3NTAgADAwMDAwMDAwMDAwIDEzMTUwNzQwNjE1IDAxMzMwNAAgNQAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='

manifest_json = '[{"Config":"0eb0091592b3d8aab929e19041330d307e0e3302cf58ae8753276a2860c45037.json","RepoTags":["python:3.4.5-alpine"],"Layers":["03a7cf8d4e91afbb8454bb11226daa7eb5705cb952d42e7a40dbee41ff59beac/layer.tar","71c4cfee4e665ad522e3d1ab02b699ec2e21370c067d94fbf7e2028b4b4cd724/layer.tar","d55df8e0fb29678f0081a0a740e456a5325d5b29b3bcaeb66377a799c3e7245e/layer.tar","b85bca58d753ad29fe017a57c87dbc3dfae4317a230e2dbe785c07f46c72086e/layer.tar"]}]'


if __name__ == '__main__':
    unittest.main()
